<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>$sce服务安全处理html数据</title>
		<script src="../org/angular.min.js"></script>
		<script src="../org/jquery.min.js" ></script>
	</head>
	<body>
		<div ng-app="hd" ng-controller="ctrl">
			{{data}}
			<hr />
			<div ng-bind-html="data"></div>
			<hr />
			<div ng-bind-html="title | trustAsHtml"></div>
		</div>
		<script>
			var m = angular.module('hd',[]);
			m.filter('trustAsHtml',['$sce',function($sce){
				return function(data){
					return $sce.trustAsHtml(data);
				}
			}])
			m.controller('ctrl',['$scope','$sce',function($scope,$sce){
				$scope.data = "<h1>renrenren</h1>";
				$scope.data = $sce.trustAsHtml('<h1>renrenren</h1>');
				$scope.title = "<h3>renrenren</h3>";
			}]);
		</script>
	</body>
</html>

